<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
</head>
<body>
<div id="app">
	<div id="header" class="wrap">
		<img src="images/logo.gif" />
	</div>
	<div id="login" class="wrap">
		<div class="main">
			<div class="corner"></div>
			<div class="introduce">
				<h2>源辰信息</h2>
				<p>网上调查系统...</p>
			</div>
			<div class="login">
				<h2>用户登录</h2>
				<form method="post" action="index.html">
					<dl id="loginBox">
						<dt>用户名：</dt>
						<dd><input v-model="uname" type="text" class="input-text" name="userId"  value=""/></dd>
						<dt>密　码：</dt>
						<dd><input v-model="pwd" type="password" class="input-text" name="password"  value=""/></dd>
						<dt></dt>
						<dd><input @click.prevent="login" type="submit" class="input-button" name="submit" value="登录" />
							<a href="register.html">新用户注册</a></dd>
					</dl>
				</form>
				<div class="error"></div>
			</div>
		</div>
	</div>
	<div class="wrap">
	</div>
	<div id="footer" class="wrap">
		源辰信息 &copy; 版权所有
	</div>
</div>
<script src="js/vue.min.js"></script>
<script src="js/axios.min.js"></script>
<script>
	var v = new Vue({
		el:"#app",
		data:{uname:"",pwd:""},
		methods:{
			login(){
				let p = new URLSearchParams();
				p.append("uname",this.uname);
				p.append("pwd",this.pwd);
				axios.post("/demovote/user/login",p).then(res=>{
					if (res.data.code == 1) {
						if(res.data.data.url){
							location.href=res.data.data.url;
						} else {
							location.href="index.html";
						}
					} else {
						alert(res.data.msg);
					}
				})
			}
		},
		created(){
			window.setTimeout(()=>{
				if (location.search == "?1") {
					alert("请先登录系统！");
				}
			},200)
		}
	})
</script>
</body>
</html>
